From: Joey Hess Date: Wed, 29 Jan 2025 18:52:20 +0000 (-0400) Subject: fix windows build and clarify comment X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~6^2~158^2~59 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=4e999af7ac5769b998c0467fe3ff56b1e874ce65;p=git-annex.git fix windows build and clarify comment --- diff --git a/Utility/OsPath.hs b/Utility/OsPath.hs index 0af093da92..c2388ed940 100644 --- a/Utility/OsPath.hs +++ b/Utility/OsPath.hs @@ -53,36 +53,39 @@ instance OsPathConv FilePath where #ifdef WITH_OSPATH instance OsPathConv RawFilePath where - toOsPath = bytesToOsPath . S.toShort #if defined(mingw32_HOST_OS) + toOsPath = bytesToOsPath fromOsPath = bytesFromOsPath #else + toOsPath = bytesToOsPath . S.toShort fromOsPath = S.fromShort . bytesFromOsPath #endif instance OsPathConv ShortByteString where - toOsPath = bytesToOsPath #if defined(mingw32_HOST_OS) + toOsPath = bytesToOsPath . S.fromShort fromOsPath = S.toShort . bytesFromOsPath #else + toOsPath = bytesToOsPath fromOsPath = bytesFromOsPath #endif -bytesToOsPath :: ShortByteString -> OsPath #if defined(mingw32_HOST_OS) -- On Windows, OsString contains a ShortByteString that is --- utf-16 encoded. So have to convert the input to that. --- This is relatively expensive. +-- utf-16 encoded. But the input RawFilePath is assumed to +-- be utf-8. So this is a relatively expensive conversion. +bytesToOsPath :: RawFilePath -> OsPath bytesToOsPath = unsafePerformIO . encodeFS . fromRawFilePath #else +bytesToOsPath :: ShortByteString -> OsPath bytesToOsPath = OsString . PosixString #endif #if defined(mingw32_HOST_OS) bytesFromOsPath :: OsPath -> RawFilePath -- On Windows, OsString contains a ShortByteString that is --- utf-16 encoded. So have to convert the input from that. --- This is relatively expensive. +-- utf-16 encoded, but RawFilePath is utf-8. +-- So this is relatively expensive conversion. bytesFromOsPath = toRawFilePath . cWcharsToChars_UCS2 . BS16.unpack . getWindowsString #else bytesFromOsPath :: OsPath -> ShortByteString